function get_cookie(cookie, key) {
    var reg = new RegExp("(?:^|\\s)" + key + "=([^;]*)(?:;|$)");
    var matches = reg.exec(cookie);
    if (matches) {
        try {
            return decodeURIComponent(matches[1]);
        } catch (_a) {
            return matches[1];
        }
    } else {
        return null;
    }
};

function decodeMap(str) {
    var result = [];
    for (var i = 0, l = str.length; i < l; i++) {
        if (result.indexOf(str[i]) === -1) {
            result.push(str[i]);
        }
    }
    return result;
}

function puzzleMap(cookie) {
    var bn = get_cookie(cookie, '__bn');
    return bn ? (0, decodeMap)(bn) : null;
};


function decode(str, map) {
    var result = [];
    var resultCur = '';

    for (var i = 0, l = str.length; i < l; i++) {
        if (map.includes(str[i])) {
            resultCur += str[i];
        } else if (resultCur) {
            result.push(resultCur);
            resultCur = '';
        }
    }

    if (resultCur) {
        result.push(resultCur);
    }
    return result;
}


function transfer(arr, map) {
    var result = [];
    var len = map.length;

    for (var i = 0, l = arr.length; i < l; i++) {
        var num = 0;
        var bit = 0;
        for (var j = arr[i].length; j--;) {
            num += map.indexOf(arr[i][j]) * Math.pow(len, bit++);
        }
        result.push(num);
    }
    if (result.length == 0){
        result=[0,0];
    }
    return result;
}

function get_data(cookie, data) {
    var map = puzzleMap(cookie)
    return transfer(decode(data, map), map)
}

